package com.uzai.console.web.tb.tbtokennew;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.tb.tbtokennew.*;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.tb.tbtokennew.TbTokenNewService;
import com.uzai.console.vo.tb.tbtokennew.TbTokenNewAuthUrlVo;
import com.uzai.console.vo.tb.tbtokennew.TbTokenNewInfoVo;
import com.uzai.console.vo.tb.tbtokennew.TbTokenNewPageVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 产品
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "新淘宝联盟",tags = "新淘宝|新淘宝联盟")
@ApiSort(9)
@RestController
public class TbTokenNewController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(TbTokenNewController.class);

    @Autowired
    private TbTokenNewService tbTokenNewService;

    @ApiOperation(value = "分页查询新淘宝联盟列表", notes = "分页查询新淘宝联盟列表", response = TbTokenNewPageVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/tbTokenNew/findTbTokenNewList")
    public Object findTbTokenNewList(@RequestBody TbTokenNewQuery tbTokenNewQuery){
        //查询新淘宝
        tbTokenNewQuery.setType(0);
        return tbTokenNewService.findTbTokenNewList(tbTokenNewQuery);
    }

    @SystemLogType(model = SystemModelEnum.TbTokenNew, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "启用炮灰", notes = "启用炮灰")
    @ApiOperationSupport(order = 2)
    @PostMapping("/tbTokenNew/setPh")
    public Object setPh(@RequestBody TbTokenNewSetPhDto tbTokenNewSetPhDto){
        tbTokenNewService.setPh(tbTokenNewSetPhDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TbTokenNew, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "启用辅助", notes = "启用辅助" )
    @ApiOperationSupport(order = 3)
    @PostMapping("/tbTokenNew/setAux")
    public Object setAux(@RequestBody TbTokenNewSetAuxDto tbTokenNewSeAuxDto){
        tbTokenNewService.setAux(tbTokenNewSeAuxDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TbTokenNew, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加联盟账号", notes = "添加联盟账号", response = TbTokenNewAuthUrlVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/tbTokenNew/addToken")
    public Object addToken(){
        return tbTokenNewService.addTbTokenNew(getLoginInfo().getMerId());
    }

    @SystemLogType(model = SystemModelEnum.TbTokenNew, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "重新授权", notes = "重新授权", response = TbTokenNewAuthUrlVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/tbTokenNew/reauthorize")
    public Object reauthorize(){
        return tbTokenNewService.addTbTokenNew(getLoginInfo().getMerId());
    }

    @ApiOperation(value = "查询联盟详情", notes = "查询联盟详情", response = TbTokenNewInfoVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/tbTokenNew/findTbTokenNewInfo")
    public Object findTbTokenNewInfo(@RequestBody TbTokenNewIdDto tbTokenNewIdDto){
        return tbTokenNewService.findTbTokenNewInfo(tbTokenNewIdDto);
    }

    @SystemLogType(model = SystemModelEnum.TbTokenNew, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "设置推广位", notes = "设置推广位")
    @ApiOperationSupport(order = 7)
    @PostMapping("/tbTokenNew/updatePid")
    public Object updatePid(@RequestBody TbTokenNewUpdatePidDto tbTokenNewUpdatePidDto){
        tbTokenNewService.updatePid(tbTokenNewUpdatePidDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TbTokenNew, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "是否同步订单", notes = "是否同步订单")
    @ApiOperationSupport(order = 8)
    @PostMapping("/tbTokenNew/setIsSyncOrder")
    public Object setIsSyncOrder(@RequestBody TbTokenNewIsSyncOrderDto tbTokenNewIsSyncOrderDto){
        tbTokenNewService.setIsSyncOrder(tbTokenNewIsSyncOrderDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TbTokenNew, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除", notes = "删除")
    @ApiOperationSupport(order = 9)
    @PostMapping("/tbTokenNew/deleteTbTokenNew")
    public Object deleteTbTokenNew(@RequestBody TbTokenNewIdDto tbTokenNewIdDto){
        tbTokenNewService.deleteTbTokenNew(tbTokenNewIdDto);
        return true;
    }


}
